<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width, initial-scale=1">
		<link rel="shortcut icon" href="http://yangwenxue.oschina.io/images/favicon.ico">
		<link rel="stylesheet" href="http://yangwenxue.oschina.io/css/font-awesome.min.css" type="text/css">
		<link rel="stylesheet" href="http://yangwenxue.oschina.io/css/boostrap/bootstrap-4.0.0-beta.1.css"> </head>
	<script src="http://yangwenxue.oschina.io/js/jquery/jquery.min.js"></script>
	<script type="text/javascript" src="../js/common.js"></script>

	<body>
		<div class="py-5">
			<div class="container">
				<div class="row">
					<div class="col-md-12">
						<ul class="breadcrumb" style="margin-bottom:0px;margin-top:0px">
							<li class="breadcrumb-item">
								<a href="https://yangwenxue.oschina.io">首页</a>
							</li>
							<li class="breadcrumb-item active">面试资源(暂未开通)</li>
							<li class="breadcrumb-item active">公司查询</li>
						</ul>
					</div>
				</div>
			</div>
		</div>
		<form class="" method="post" id="search-form">
			<div class="container">
				<div class="row">
					<div class="col-md-4">
						<div class="form-group"> <label>公司名称</label>
							<input type="text" name="companyName" class="form-control" placeholder="公司名称"> </div>
						<div class="form-group"> <label>是否要求学历</label>
							<select class="form-control" name="isEdu">
								<option value="">--请选择--</option>
								<option value="0">不要求</option>
								<option value="1">本科及以上</option>
							</select>
						</div>
					</div>
					<div class="col-md-4">
						<div class="form-group"> <label>公司地址</label>
							<input type="text" name="companyAddress" class="form-control" placeholder="公司地址"> </div>
						<div class="form-group"> <label>排序</label>
							<select class="form-control" name="orderby">
								<option value="0">综合(优先人气指数)</option>
								<option value="1">时间倒叙</option>
								<option value="2">人气倒叙</option>
							</select>
						</div>
					</div>
					<div class="col-md-4">
						<div class="form-group"> <label>学科</label>
							<select class="form-control" name="recruitTypeId">
								<option value="">--请选择--</option>
								<option value="1">JavaEE</option>
								<option value="2">PHP</option>
								<option value="3">Python</option>
							</select>
						</div>
						<div class="form-group"> <label></label>
							<button type="button" id="btn-search-form" class="btn btn-primary">搜索</button>
						</div>
					</div>
				</div>
				<div class="row">
					<div class="col-md-12">
						<table class="table" id="show-tables">
							<thead>
								<tr>
									<th>公司名称</th>
									<th>要求学历</th>
									<th>学科</th>
									<th>操作</th>
								</tr>
							</thead>
							<tbody>
								<tr>
									<td>百度</td>
									<td>是</td>
									<td>java</td>
									<td>
										<a href="company_info.html">查看</a>
										<a href="company_edit.html">修改</a>
									</td>
								</tr>
								<tr>
									<td class="text-center" colspan="4">
										<a href="company_add.html" onclick="">新增</a>
									</td>
								</tr>
							</tbody>
						</table>
					</div>
				</div>
				<div class="row">
					<div class="col-md-12">
						<ul class="pagination pager" style="float: right; margin-right: 10%;">
							<li class="previous disabled">
								<a href="#" onclick="prev_search()">上一页</a>
							</li>
							<li class="previous disabled">
								<select id="pageNo" name="pageNo" onchange="search()" style="width:50PX;margin-right:10px;margin-left:10px;">
								</select>
							</li>
							<li class="next">
								<a href="#" onclick="next_search()">下一页</a>
							</li>
						</ul>
					</div>
				</div>
			</div>
		</form>
		<div class="py-5">
			<div class="container">
				<div class="row">
					<div class="col-md-12 mt-3 text-center">
						<p>© 2017-Yokol.top版权所有-
							<a href="http://www.beian.gov.cn/portal/registerSystemInfo?recordcode=17061202" target="_blank">&nbsp;京ICP备17061202号 </a>
						</p>
					</div>
				</div>
			</div>
		</div>
		<script>
			$(function() {
				initDict();
				search();
			});
			$("#btn-search-form").click(function() {
				$("#pageNo").val(1);
				search();
			});

			function initDict() {
				$.ajax({
					url: resPath_work + "dict/getDictList",
					type: "post",
					dataType: 'json',
					success: function(data) {
						if(data.status != "200") {
							alert(data.msg);
							return;
						}
						$("select[name=recruitTypeId]").html("");
						var resList = data.data;
						var htmlCode = '<option value="">--请选择--</option>';
						for(var i = 0; i < resList.length; i++) {
							var code = resList[i];
							htmlCode += '<option value="' + code.id + '">' + code.dicValue + '</option>';
						}
						$("select[name=recruitTypeId]").append(htmlCode);
					},
					error: function() {
						alert("获取字典列表失败");
					}
				});
			};

			// 上一页
			function prev_search() {
				var pageNo = $("#pageNo").val();
				if(pageNo == 1) return false;
				$("#pageNo").val(pageNo - 1 >= 0 ? parseInt(pageNo) - 1 : 1);
				search();
			}
			// 下一页
			function next_search() {
				var pageNo = $("#pageNo").val();
				var pagetotal = $("#pageNo option:last").attr("value");
				if(pageNo == pagetotal) return false;
				$("#pageNo").val(pageNo + 1 < pagetotal ? parseInt(pageNo) + 1 : pagetotal);
				search();
			}
			/*
			 * 按照条件查询所有的数据
			 * */
			function search() {
				$.ajax({
					url: resPath_work + "company/getCompanyList",
					type: "post",
					data: $("#search-form").serializeJson(),
					dataType: 'json',
					success: function(data) {
						if(data.status != "200") {
							alert(data.msg);
							return;
						}
						$("#pageNo").html("");
						$("#show-tables tbody").html("");
						var resList = data.data.entitys;
						var htmlCode = "";
						for(var i = 0; i < resList.length; i++) {
							var code = resList[i];
							htmlCode += '<tr>' +
								'<td>' + code.companyName + '</td>' +
								'<td>' + (code.isEdu == 0 ? '否' : '是') + '</td>' +
								'<td>' + code.recruitType + '</td>' +
								'<td>' +
								'<a href="company_info.html?id=' + code.id + '">查看</a> ' +
								' <a href="company_edit.html?id=' + code.id + '">修改</a>' +
								'</td>' +
								'</tr>';
						}
						htmlCode += '<tr>' +
							'<td class="text-center" colspan="4">' +
							'<a href="company_add.html" onclick="">新增</a>' +
							'</td>' +
							'</tr>';
						$("#show-tables tbody").append(htmlCode);
						for(var i = 1; i <= data.data.totalPageNum; i++) {
							$("#pageNo").append('<option value="' + i + '">' + i + '</option>')
						}
						$("#pageNo").val(data.data.currentPageNum);
					},
					error: function() {
						alert("获取公司列表失败");
					}
				});
			};
		</script>
	</body>

</html>